﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
using Elderos.Highlight;
using Elderos.Utils.Logging;

namespace WinTcpHighlightService
{
    public partial class WinTcpHighlightService : ServiceBase
    {
        private ServiceHost _host;

        public WinTcpHighlightService()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                Type serviceType = typeof(WcfHighlighterService);
                _host = new ServiceHost(serviceType);
                _host.Open();
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message);
                throw;
            }
        }

        protected override void OnStop()
        {
            if (_host != null)
                _host.Close();
        }
    }
}
